package com.ws.controller;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.ws.bean.MaintenanceRecord;
import com.ws.bean.ReturnCheck;
import com.ws.common.CommonResult;
import com.ws.service.MaintenanceRecordService;
import com.ws.util.Page;


@RestController
@RequestMapping("tenance")
public class MaintenanceRecordController {
	@Autowired
	MaintenanceRecordService service;
	@GetMapping("select")
	public CommonResult getRecords(MaintenanceRecord record,Page page) {
		List<MaintenanceRecord> list = service.getRecords(record,page);
		int count = service.getCount(record);
		Map map = new HashMap<>();
		map.put("list", list);
		map.put("count", count);
		return CommonResult.success(map);
	}
	@DeleteMapping("del/{id}")
	public CommonResult delRecord(@PathVariable Integer id) {
		int result = service.delRecord(id);
		return CommonResult.success();
	}
	@PostMapping("add")
	public CommonResult addRecord(@RequestBody MaintenanceRecord record) {
		int result = service.addRecord(record);
		return CommonResult.success();
	}
	@PutMapping("edit")
	public CommonResult editRecord(MaintenanceRecord record) {
		int result = service.editRecord(record);
		return CommonResult.success();
	}
	@GetMapping("getcheck")
	public CommonResult getCheck() {
		List<ReturnCheck> list = service.getCheck();
		return CommonResult.success(list);
	}
	@GetMapping("getstaff")
	public CommonResult getStaff() {
		List<ReturnCheck> list = service.getStaff();
		return CommonResult.success(list);
	}
}
